<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Skew Normal Distribution</title>
<link rel="stylesheet" href="../../../math.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../../index.html" title="Math Toolkit 4.2.1">
<link rel="up" href="../dists.html" title="Distributions">
<link rel="prev" href="rayleigh.html" title="Rayleigh Distribution">
<link rel="next" href="students_t_dist.html" title="Students t Distribution">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="rayleigh.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../dists.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="students_t_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="math_toolkit.dist_ref.dists.skew_normal_dist"></a><a class="link" href="skew_normal_dist.html" title="Skew Normal Distribution">Skew
        Normal Distribution</a>
</h4></div></div></div>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">distributions</span><span class="special">/</span><span class="identifier">skew_normal</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></pre>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">math</span><span class="special">{</span>

<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">RealType</span> <span class="special">=</span> <span class="keyword">double</span><span class="special">,</span>
          <span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter 22. Policies: Controlling Precision, Error Handling etc">Policy</a>   <span class="special">=</span> <a class="link" href="../../pol_ref/pol_ref_ref.html" title="Policy Class Reference">policies::policy&lt;&gt;</a> <span class="special">&gt;</span>
<span class="keyword">class</span> <span class="identifier">skew_normal_distribution</span><span class="special">;</span>

<span class="keyword">typedef</span> <span class="identifier">skew_normal_distribution</span><span class="special">&lt;&gt;</span> <span class="identifier">normal</span><span class="special">;</span>

<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">RealType</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter 22. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
<span class="keyword">class</span> <span class="identifier">skew_normal_distribution</span>
<span class="special">{</span>
<span class="keyword">public</span><span class="special">:</span>
   <span class="keyword">typedef</span> <span class="identifier">RealType</span> <span class="identifier">value_type</span><span class="special">;</span>
   <span class="keyword">typedef</span> <span class="identifier">Policy</span>   <span class="identifier">policy_type</span><span class="special">;</span>
   <span class="comment">// Constructor:</span>
   <span class="identifier">skew_normal_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">location</span> <span class="special">=</span> <span class="number">0</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">scale</span> <span class="special">=</span> <span class="number">1</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">shape</span> <span class="special">=</span> <span class="number">0</span><span class="special">);</span>
   <span class="comment">// Accessors:</span>
   <span class="identifier">RealType</span> <span class="identifier">location</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span> <span class="comment">// mean if normal.</span>
   <span class="identifier">RealType</span> <span class="identifier">scale</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span> <span class="comment">// width, standard deviation if normal.</span>
   <span class="identifier">RealType</span> <span class="identifier">shape</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span> <span class="comment">// The distribution is right skewed if shape &gt; 0 and is left skewed if shape &lt; 0.</span>
                          <span class="comment">// The distribution is normal if shape is zero.</span>
<span class="special">};</span>

<span class="special">}}</span> <span class="comment">// namespaces</span>
</pre>
<p>
          The skew normal distribution is a variant of the most well known Gaussian
          statistical distribution.
        </p>
<p>
          The skew normal distribution with shape zero resembles the <a href="http://en.wikipedia.org/wiki/Normal_distribution" target="_top">Normal
          Distribution</a>, hence the latter can be regarded as a special case
          of the more generic skew normal distribution.
        </p>
<p>
          If the standard (mean = 0, scale = 1) normal distribution probability density
          function is
        </p>
<div class="blockquote"><blockquote class="blockquote"><p>
            <span class="inlinemediaobject"><img src="../../../../equations/normal01_pdf.svg"></span>

          </p></blockquote></div>
<p>
          and the cumulative distribution function
        </p>
<div class="blockquote"><blockquote class="blockquote"><p>
            <span class="inlinemediaobject"><img src="../../../../equations/normal01_cdf.svg"></span>

          </p></blockquote></div>
<p>
          then the <a href="http://en.wikipedia.org/wiki/Probability_density_function" target="_top">PDF</a>
          of the <a href="http://en.wikipedia.org/wiki/Skew_normal_distribution" target="_top">skew
          normal distribution</a> with shape parameter α, defined by O'Hagan and
          Leonhard (1976) is
        </p>
<div class="blockquote"><blockquote class="blockquote"><p>
            <span class="inlinemediaobject"><img src="../../../../equations/skew_normal_pdf0.svg"></span>

          </p></blockquote></div>
<p>
          Given <a href="http://en.wikipedia.org/wiki/Location_parameter" target="_top">location</a>
          ξ, <a href="http://en.wikipedia.org/wiki/Scale_parameter" target="_top">scale</a>
          ω, and <a href="http://en.wikipedia.org/wiki/Shape_parameter" target="_top">shape</a>
          α, it can be <a href="http://en.wikipedia.org/wiki/Skew_normal_distribution" target="_top">transformed</a>,
          to the form:
        </p>
<div class="blockquote"><blockquote class="blockquote"><p>
            <span class="inlinemediaobject"><img src="../../../../equations/skew_normal_pdf.svg"></span>

          </p></blockquote></div>
<p>
          and <a href="http://en.wikipedia.org/wiki/Cumulative_distribution_function" target="_top">CDF</a>:
        </p>
<div class="blockquote"><blockquote class="blockquote"><p>
            <span class="inlinemediaobject"><img src="../../../../equations/skew_normal_cdf.svg"></span>

          </p></blockquote></div>
<p>
          where <span class="emphasis"><em>T(h,a)</em></span> is Owen's T function, and <span class="emphasis"><em>Φ(x)</em></span>
          is the normal distribution.
        </p>
<p>
          The variation the PDF and CDF with its parameters is illustrated in the
          following graphs:
        </p>
<div class="blockquote"><blockquote class="blockquote"><p>
            <span class="inlinemediaobject"><img src="../../../../graphs/skew_normal_pdf.svg" align="middle"></span>

          </p></blockquote></div>
<div class="blockquote"><blockquote class="blockquote"><p>
            <span class="inlinemediaobject"><img src="../../../../graphs/skew_normal_cdf.svg" align="middle"></span>

          </p></blockquote></div>
<h5>
<a name="math_toolkit.dist_ref.dists.skew_normal_dist.h0"></a>
          <span class="phrase"><a name="math_toolkit.dist_ref.dists.skew_normal_dist.member_functions"></a></span><a class="link" href="skew_normal_dist.html#math_toolkit.dist_ref.dists.skew_normal_dist.member_functions">Member
          Functions</a>
        </h5>
<pre class="programlisting"><span class="identifier">skew_normal_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">location</span> <span class="special">=</span> <span class="number">0</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">scale</span> <span class="special">=</span> <span class="number">1</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">shape</span> <span class="special">=</span> <span class="number">0</span><span class="special">);</span>
</pre>
<p>
          Constructs a skew_normal distribution with location ξ, scale ω and shape α.
        </p>
<p>
          Requires scale &gt; 0, otherwise <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
          is called.
        </p>
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">location</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
</pre>
<p>
          returns the location ξ of this distribution,
        </p>
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">scale</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
</pre>
<p>
          returns the scale ω of this distribution,
        </p>
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">shape</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
</pre>
<p>
          returns the shape α of this distribution.
        </p>
<p>
          (Location and scale function match other similar distributions, allowing
          the functions <code class="computeroutput"><span class="identifier">find_location</span></code>
          and <code class="computeroutput"><span class="identifier">find_scale</span></code> to be used
          generically).
        </p>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top">
<p>
            While the shape parameter may be chosen arbitrarily (finite), the resulting
            <span class="bold"><strong>skewness</strong></span> of the distribution is in fact
            limited to about (-1, 1); strictly, the interval is (-0.9952717, 0.9952717).
          </p>
<p>
            A parameter δ is related to the shape α by δ = α / (1 + α²), and used in the expression
            for skewness
          </p>
<div class="blockquote"><blockquote class="blockquote"><p>
              <span class="inlinemediaobject"><img src="../../../../equations/skew_normal_skewness.svg"></span>

            </p></blockquote></div>
</td></tr>
</table></div>
<h5>
<a name="math_toolkit.dist_ref.dists.skew_normal_dist.h1"></a>
          <span class="phrase"><a name="math_toolkit.dist_ref.dists.skew_normal_dist.references"></a></span><a class="link" href="skew_normal_dist.html#math_toolkit.dist_ref.dists.skew_normal_dist.references">References</a>
        </h5>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <a href="http://azzalini.stat.unipd.it/SN/" target="_top">Skew-Normal Probability
              Distribution</a> for many links and bibliography.
            </li>
<li class="listitem">
              <a href="http://azzalini.stat.unipd.it/SN/Intro/intro.html" target="_top">A very
              brief introduction to the skew-normal distribution</a> by Adelchi
              Azzalini (2005-11-2).
            </li>
<li class="listitem">
              See a <a href="http://www.tri.org.au/azzalini.html" target="_top">skew-normal
              function animation</a>.
            </li>
</ul></div>
<h5>
<a name="math_toolkit.dist_ref.dists.skew_normal_dist.h2"></a>
          <span class="phrase"><a name="math_toolkit.dist_ref.dists.skew_normal_dist.non_member_accessors"></a></span><a class="link" href="skew_normal_dist.html#math_toolkit.dist_ref.dists.skew_normal_dist.non_member_accessors">Non-member
          Accessors</a>
        </h5>
<p>
          All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor
          functions</a> that are generic to all distributions are supported:
          <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>,
          <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>,
          <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.quantile">Quantile</a>, <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.hazard">Hazard Function</a>, <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.chf">Cumulative Hazard Function</a>,
          <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.mean">mean</a>, <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.median">median</a>,
          <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.mode">mode</a>, <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.variance">variance</a>,
          <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
          <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.skewness">skewness</a>, <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.kurtosis">kurtosis</a>, <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.kurtosis_excess">kurtosis_excess</a>,
          <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.range">range</a> and <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.support">support</a>.
        </p>
<p>
          The domain of the random variable is <span class="emphasis"><em>-[max_value], +[min_value]</em></span>.
          Infinite values are not supported.
        </p>
<p>
          There are no <a href="http://en.wikipedia.org/wiki/Closed-form_expression" target="_top">closed-form
          expression</a> known for the mode and median, but these are computed
          for the
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              mode - by finding the maximum of the PDF.
            </li>
<li class="listitem">
              median - by computing <code class="computeroutput"><span class="identifier">quantile</span><span class="special">(</span><span class="number">1</span><span class="special">/</span><span class="number">2</span><span class="special">)</span></code>.
            </li>
</ul></div>
<p>
          The maximum of the PDF is sought through searching the root of f'(x)=0.
        </p>
<p>
          Both involve iterative methods that will have lower accuracy than other
          estimates.
        </p>
<h5>
<a name="math_toolkit.dist_ref.dists.skew_normal_dist.h3"></a>
          <span class="phrase"><a name="math_toolkit.dist_ref.dists.skew_normal_dist.testing"></a></span><a class="link" href="skew_normal_dist.html#math_toolkit.dist_ref.dists.skew_normal_dist.testing">Testing</a>
        </h5>
<p>
          <a href="http://www.r-project.org/" target="_top">The R Project for Statistical Computing</a>
          using library(sn) described at <a href="http://azzalini.stat.unipd.it/SN/" target="_top">Skew-Normal
          Probability Distribution</a>, and at <a href="http://cran.r-project.org/web/packages/sn/sn.pd" target="_top">R
          skew-normal(sn) package</a>.
        </p>
<p>
          Package sn provides functions related to the skew-normal (SN) and the skew-t
          (ST) probability distributions, both for the univariate and for the the
          multivariate case, including regression models.
        </p>
<p>
          <a href="http://www.wolfram.com/products/mathematica/index.html" target="_top">Wolfram
          Mathematica</a> was also used to generate some more accurate spot test
          data.
        </p>
<h5>
<a name="math_toolkit.dist_ref.dists.skew_normal_dist.h4"></a>
          <span class="phrase"><a name="math_toolkit.dist_ref.dists.skew_normal_dist.accuracy"></a></span><a class="link" href="skew_normal_dist.html#math_toolkit.dist_ref.dists.skew_normal_dist.accuracy">Accuracy</a>
        </h5>
<p>
          The skew_normal distribution with shape = zero is implemented as a special
          case, equivalent to the normal distribution in terms of the <a class="link" href="../../sf_erf/error_function.html" title="Error Function erf and complement erfc">error
          function</a>, and therefore should have excellent accuracy.
        </p>
<p>
          The PDF and mean, variance, skewness and kurtosis are also accurately evaluated
          using <a href="http://en.wikipedia.org/wiki/Analytical_expression" target="_top">analytical
          expressions</a>. The CDF requires <a href="http://en.wikipedia.org/wiki/Owen%27s_T_function" target="_top">Owen's
          T function</a> that is evaluated using a Boost C++ <a class="link" href="../../owens_t.html" title="Owen's T function">Owens
          T</a> implementation of the algorithms of M. Patefield and D. Tandy,
          Journal of Statistical Software, 5(5), 1-25 (2000); the complicated accuracy
          of this function is discussed in detail at <a class="link" href="../../owens_t.html" title="Owen's T function">Owens
          T</a>.
        </p>
<p>
          The median and mode are calculated by iterative root finding, and both
          will be less accurate.
        </p>
<h5>
<a name="math_toolkit.dist_ref.dists.skew_normal_dist.h5"></a>
          <span class="phrase"><a name="math_toolkit.dist_ref.dists.skew_normal_dist.implementation"></a></span><a class="link" href="skew_normal_dist.html#math_toolkit.dist_ref.dists.skew_normal_dist.implementation">Implementation</a>
        </h5>
<p>
          In the following table, ξ is the location of the distribution, and ω is its
          scale, and α is its shape.
        </p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
                  <p>
                    Function
                  </p>
                </th>
<th>
                  <p>
                    Implementation Notes
                  </p>
                </th>
</tr></thead>
<tbody>
<tr>
<td>
                  <p>
                    pdf
                  </p>
                </td>
<td>
                  <p>
                    Using:
                  </p>
                  <div class="blockquote"><blockquote class="blockquote"><p>
                      <span class="inlinemediaobject"><img src="../../../../equations/skew_normal_pdf.svg"></span>

                    </p></blockquote></div>
                </td>
</tr>
<tr>
<td>
                  <p>
                    cdf
                  </p>
                </td>
<td>
                  <p>
                    Using:
                  </p>
                  <div class="blockquote"><blockquote class="blockquote"><p>
                      <span class="inlinemediaobject"><img src="../../../../equations/skew_normal_cdf.svg"></span>

                    </p></blockquote></div>
                  <p>
                    <br> where <span class="emphasis"><em>T(h,a)</em></span> is Owen's T function,
                    and <span class="emphasis"><em>Φ(x)</em></span> is the normal distribution.
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    cdf complement
                  </p>
                </td>
<td>
                  <p>
                    Using: complement of normal distribution + 2 * Owens_t
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    quantile
                  </p>
                </td>
<td>
                  <p>
                    Maximum of the pdf is sought through searching the root of f'(x)=0
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    quantile from the complement
                  </p>
                </td>
<td>
                  <p>
                    -quantile(SN(-location ξ, scale ω, -shapeα), p)
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    location
                  </p>
                </td>
<td>
                  <p>
                    location ξ
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    scale
                  </p>
                </td>
<td>
                  <p>
                    scale ω
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    shape
                  </p>
                </td>
<td>
                  <p>
                    shape α
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    median
                  </p>
                </td>
<td>
                  <p>
                    quantile(1/2)
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    mean
                  </p>
                </td>
<td>
                  <div class="blockquote"><blockquote class="blockquote"><p>
                      <span class="inlinemediaobject"><img src="../../../../equations/skew_normal_mean.svg"></span>

                    </p></blockquote></div>
                </td>
</tr>
<tr>
<td>
                  <p>
                    mode
                  </p>
                </td>
<td>
                  <p>
                    Maximum of the pdf is sought through searching the root of f'(x)=0
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    variance
                  </p>
                </td>
<td>
                  <div class="blockquote"><blockquote class="blockquote"><p>
                      <span class="inlinemediaobject"><img src="../../../../equations/skew_normal_variance.svg"></span>

                    </p></blockquote></div>
                </td>
</tr>
<tr>
<td>
                  <p>
                    skewness
                  </p>
                </td>
<td>
                  <div class="blockquote"><blockquote class="blockquote"><p>
                      <span class="inlinemediaobject"><img src="../../../../equations/skew_normal_skewness.svg"></span>

                    </p></blockquote></div>
                </td>
</tr>
<tr>
<td>
                  <p>
                    kurtosis
                  </p>
                </td>
<td>
                  <p>
                    kurtosis excess-3
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    kurtosis excess
                  </p>
                </td>
<td>
                  <div class="blockquote"><blockquote class="blockquote"><p>
                      <span class="inlinemediaobject"><img src="../../../../equations/skew_normal_kurt_ex.svg"></span>

                    </p></blockquote></div>
                </td>
</tr>
</tbody>
</table></div>
</div>
<div class="copyright-footer">Copyright © 2006-2021 Nikhar Agrawal, Anton Bikineev, Matthew Borland,
      Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert Holin, Bruno
      Lalande, John Maddock, Evan Miller, Jeremy Murphy, Matthew Pulver, Johan Råde,
      Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg, Daryle
      Walker and Xiaogang Zhang<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="rayleigh.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../dists.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="students_t_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
